<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>

<script>
$('a[data-typeid="30"]').addClass("am-btn-primary");
var queryParams = {};
var tables = $('#dataTables').DataTable({
    "sAjaxSource" : '{{ urlfor "InventoryController.Inventory"}}'
    ,"bLengthChange": false
    ,"fnServerData" : function(sSource, aoData, fnCallback) {
        queryParams = checkQueryTableData(aoData);
        queryParams.typeid = 30;
        var form = $('.query-form').serializeArray();
        $.each(form, function(i, value){
            queryParams[value.name] = value.value;
        });
        $.post(sSource, JSON.stringify(queryParams),function(resp) {
            fnCallback(resp);
        },'json')
    }
    ,columns: [
        {render:function(data, type, full, meta) {
            return full.Products.BrandName;
        }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Products.Name;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Products.Suppliers.Name;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Products.MaterialQuality;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Products.Unit;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.model;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.color;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.size;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.Snd.genre;
            }, "bSortable": false}
        ,{render:function(data, type, full, meta) {
                return full.purchase_num;
            }, "bSortable": false}
    ]
    ,"aLengthMenu":[20, 50, 100, 200]
	,'bLengthChange': true
    ,"serverSide": true
    ,"bPaginate" : true
    ,"bFilter" : false	//是否启动过滤、搜索功能
    ,"bInfo" : true //是否显示页脚信息，DataTables插件左下角显示记录数
    ,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示
});

$("#query-submit").bind("click", function () { //点击按钮 触发table重新请求服务器
    $("#dataTables").dataTable().fnDraw(false);
    return false;
});

$.post('{{ urlfor "ProductsController.GetOptions"}}', {'fields':['goods_cast_away']},  function(res){
    setattroption('cast_away',res.data.goods_cast_away);
});
</script>
{{template "./inventory/p.html" .}}